home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
-
- #include <stdlib.h>
- #include <GL/glx.h>
-
- /* printVisualInfo.c
- * Prints all of the information returned by XGetVisualInfo
- * about the X visuals available for a particular display.
- */
-
- /**************************************************************************
- * Global Variables
- **************************************************************************/
-
- Display *display;
-
- enum { ZERO = 0, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN };
-
-
- /**************************************************************************
- * printVisualInfo() - Retrieve information from X visual
- **************************************************************************/
-
- static const char*
- className( int class )
- {
- static char *classes[] = {
- "StaticGray",
- "GrayScale",
- "StaticColor",
- "PseudoColor",
- "TrueColor",
- "DirectColor",
- };
-
- if ( class < ZERO || class > FIVE )
- return "unknown";
- else
- return classes[class];
- }
-
- GLvoid
- printVisualInfo( XVisualInfo *glxVisual )
- {
- int tmp;
-
- printf(" X Visual Information ...\n\n" );
- printf("\tvisualid : 0x%x\n", glxVisual->visualid );
- printf("\tclass : %s\n\n", className( glxVisual->class ) );
-
- #define TrueFalse(x) ( x ? "True" : "False" )
-
- glXGetConfig(display, glxVisual, GLX_USE_GL, &tmp);
- printf( "\tSupport GL ( GLX_USE_GL ) : %s\n", TrueFalse(tmp) );
-
- glXGetConfig(display, glxVisual, GLX_LEVEL, &tmp);
- printf( "\tFramebuffer ( GLX_LEVEL ) : %s\n\n",
- tmp < ZERO ? "Underlay" : tmp > ZERO ? "Overlay" : "Normal" );
-
- glXGetConfig(display, glxVisual, GLX_BUFFER_SIZE, &tmp);
- printf( "\tFramebuffer depth ( GLX_BUFFER_SIZE ) : %d\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_DOUBLEBUFFER, &tmp);
- printf( "\tDoublebuffer ( GLX_DOUBLEBUFFER ) : %s\n",
- TrueFalse(tmp) );
-
- glXGetConfig(display, glxVisual, GLX_DEPTH_SIZE, &tmp);
- printf( "\tDepth buffer depth ( GLX_DEPTH_SIZE ) : %d\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_STENCIL_SIZE, &tmp);
- printf( "\tStencil buffer depth ( GLX_STENCIL_SIZE ) : %d\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_STEREO, &tmp);
- printf( "\tStereo Buffer ( GLX_STEREO ) : %s\n",
- TrueFalse(tmp) );
-
- glXGetConfig(display, glxVisual, GLX_AUX_BUFFERS, &tmp);
- printf( "\tAuxillary Buffers ( GLX_AUX_BUFFERS) : %d\n\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_RGBA, &tmp);
- printf( "\tColor mode ( GLX_RGBA ) : %s\n", tmp ? "RGBA" :
- "Color Index" );
-
- glXGetConfig(display, glxVisual, GLX_RED_SIZE, &tmp);
- printf( "\tRed Bits ( GLX_RED_SIZE ) : %d\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_GREEN_SIZE, &tmp);
- printf( "\tGreen Bits ( GLX_GREEN_SIZE ) : %d\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_BLUE_SIZE, &tmp);
- printf( "\tBlue Bits ( GLX_BLUE_SIZE ) : %d\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_ALPHA_SIZE, &tmp);
- printf( "\tAlpha Bits ( GLX_ALPHA_SIZE ) : %d\n\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_ACCUM_RED_SIZE, &tmp);
- printf( "\tRed Accumulation Bits ( GLX_ACCUM_RED_SIZE ) : %d\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_ACCUM_GREEN_SIZE, &tmp);
- printf( "\tGreen Accumulation Bits ( GLX_ACCUM_GREEN_SIZE ) : %d\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_ACCUM_BLUE_SIZE, &tmp);
- printf( "\tBlue Accumulation Bits ( GLX_ACCUM_BLUE_SIZE ) : %d\n", tmp );
-
- glXGetConfig(display, glxVisual, GLX_ACCUM_ALPHA_SIZE, &tmp);
- printf( "\tAlpha Accumulation Bits ( GLX_ACCUM_ALPHA_SIZE ) : %d\n\n", tmp );
- }
-
- /**************************************************************************
- * printUsage() - print program usage message
- **************************************************************************/
-
- void
- printUsage( char *programName )
- {
- printf("Usage : '%s' [-display <display>]\n", programName );
- exit( EXIT_FAILURE );
- }
-
-
- /**************************************************************************
- * main()
- **************************************************************************/
-
- void
- main( int argc, char **argv )
- {
- char *displayName = (char *) NULL;
- long i, infoMask;
- int items;
- XVisualInfo *visualInfo, infoTemplate;
-
- if ( argc != ONE ) {
- if ( !strcmp( argv[1], "-display" ) )
- displayName = argv[2];
- else
- printUsage( *argv );
- } else
- if ( (displayName = getenv( "DISPLAY" )) == (char *) NULL ) {
- printf( "\nUnable to get DISPLAY from the environment\n");
- printUsage( *argv );
- }
-
- if ( (display = XOpenDisplay( displayName )) == (Display *) NULL ) {
- printf( "\nUnable to open display '%s'\n", displayName );
- exit( EXIT_FAILURE );
- }
-
- infoMask = VisualNoMask;
-
- visualInfo = XGetVisualInfo( display, infoMask, &infoTemplate, &items );
-
- for ( i = 0; i < items; i++ )
- printVisualInfo( &visualInfo[i] );
-
- XFree( visualInfo );
- XCloseDisplay( display );
-
- exit( EXIT_SUCCESS );
- }
-